﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;
using System.Windows.Forms;
namespace BackupRestoreSoftwares
{
	public class _7zip
	{
		public static string Roaming_path = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData).ToString();
		public static string Local_path = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData).ToString();
		public static string Common_path = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData).ToString();
		public static string Program_32 = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles).ToString();
		public static string Program_64 = Path.GetPathRoot(Environment.SystemDirectory).ToString() + "Program Files";
		public static bool Is64 = Environment.Is64BitOperatingSystem;
		public static void CompressFile(string source, string target)
		{
			ProcessStartInfo p = new ProcessStartInfo();
			p.FileName = @"7za.exe";
			p.Arguments = "a -t7z \"" + target + "\" \"" + source + "\" -mx=9";
			//               1              2                       3               4
            p.WindowStyle = ProcessWindowStyle.Hidden;
			Process x = Process.Start(p);
			x.WaitForExit();
		}

		public static void ExtractFile(string source, string dest)
		{
			string zPath = @"7za.exe";
			ProcessStartInfo pro = new ProcessStartInfo();
			pro.WindowStyle = ProcessWindowStyle.Hidden;
			pro.FileName = zPath;
			pro.Arguments = "x -y \"" + source + "\" -o\"" + dest + "\"";
			Process x = Process.Start(pro);
			x.WaitForExit();
		}

		public static void DeleteCache()
		{
			if (File.Exists("DeleteCache.exe"))
			{
				string zPath_del = @"DeleteCache.exe";
				ProcessStartInfo pro_del = new ProcessStartInfo();
				pro_del.WindowStyle = ProcessWindowStyle.Hidden;
				pro_del.FileName = zPath_del;
				Process x_del = Process.Start(pro_del);
				x_del.WaitForExit();
			}
			else
			{
				MessageBox.Show("File: DeleteCache.exe not found.\nPlease Delete Cache with manual.", "File not found");
			}
        }

    }
}
